using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace AuthService.Auth.Dtos;

/// <summary>
/// 登录请求DTO
/// </summary>
public class LoginRequestDto
{
    /// <summary>
    /// 用户名
    /// </summary>
    [Required]
    public string Username { get; set; }

    /// <summary>
    /// 密码
    /// </summary>
    [Required]
    public string Password { get; set; }

    /// <summary>
    /// 客户端ID
    /// </summary>
    public string ClientId { get; set; }

    /// <summary>
    /// 客户端密钥
    /// </summary>
    public string ClientSecret { get; set; }

    /// <summary>
    /// 记住我
    /// </summary>
    public bool RememberMe { get; set; }

    /// <summary>
    /// 验证码
    /// </summary>
    public string Captcha { get; set; }

    /// <summary>
    /// 验证码密钥
    /// </summary>
    public string CaptchaKey { get; set; }
}

/// <summary>
/// 登录结果DTO
/// </summary>
public class LoginResultDto
{
    /// <summary>
    /// 访问令牌
    /// </summary>
    public string AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌
    /// </summary>
    public string RefreshToken { get; set; }

    /// <summary>
    /// 令牌类型
    /// </summary>
    public string TokenType { get; set; }

    /// <summary>
    /// 过期时间（秒）
    /// </summary>
    public int ExpiresIn { get; set; }

    /// <summary>
    /// 刷新令牌过期时间（秒）
    /// </summary>
    public int RefreshExpiresIn { get; set; }

    /// <summary>
    /// 用户上下文
    /// </summary>
    public UserContextDto UserContext { get; set; }
}

/// <summary>
/// 登出请求DTO
/// </summary>
public class LogoutRequestDto
{
    /// <summary>
    /// 访问令牌
    /// </summary>
    public string AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌
    /// </summary>
    public string RefreshToken { get; set; }

    /// <summary>
    /// 客户端ID
    /// </summary>
    public string ClientId { get; set; }
}

/// <summary>
/// 刷新令牌请求DTO
/// </summary>
public class RefreshTokenRequestDto
{
    /// <summary>
    /// 刷新令牌
    /// </summary>
    [Required]
    public string RefreshToken { get; set; }

    /// <summary>
    /// 客户端ID
    /// </summary>
    public string ClientId { get; set; }

    /// <summary>
    /// 客户端密钥
    /// </summary>
    public string ClientSecret { get; set; }
}

/// <summary>
/// 刷新令牌结果DTO
/// </summary>
public class RefreshTokenResultDto
{
    /// <summary>
    /// 访问令牌
    /// </summary>
    public string AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌
    /// </summary>
    public string RefreshToken { get; set; }

    /// <summary>
    /// 令牌类型
    /// </summary>
    public string TokenType { get; set; }

    /// <summary>
    /// 过期时间（秒）
    /// </summary>
    public int ExpiresIn { get; set; }
}

/// <summary>
/// 令牌验证结果DTO
/// </summary>
public class TokenValidationResultDto
{
    /// <summary>
    /// 是否有效
    /// </summary>
    public bool IsValid { get; set; }

    /// <summary>
    /// 用户ID
    /// </summary>
    public Guid UserId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string Username { get; set; }

    /// <summary>
    /// 过期时间
    /// </summary>
    public DateTime? ExpiresAt { get; set; }

    /// <summary>
    /// 签发时间
    /// </summary>
    public DateTime? IssuedAt { get; set; }

    /// <summary>
    /// 签发者
    /// </summary>
    public string Issuer { get; set; }

    /// <summary>
    /// 受众
    /// </summary>
    public string Audience { get; set; }

    /// <summary>
    /// 作用域
    /// </summary>
    public string[] Scope { get; set; }
}

/// <summary>
/// 用户上下文DTO
/// </summary>
public class UserContextDto
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public Guid UserId { get; set; }

    /// <summary>
    /// 用户名
    /// </summary>
    public string Username { get; set; }

    /// <summary>
    /// 邮箱
    /// </summary>
    public string Email { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string Avatar { get; set; }

    /// <summary>
    /// 角色
    /// </summary>
    public string[] Roles { get; set; }

    /// <summary>
    /// 权限
    /// </summary>
    public string[] Permissions { get; set; }

    /// <summary>
    /// 租户ID
    /// </summary>
    public Guid? TenantId { get; set; }

    /// <summary>
    /// 租户名称
    /// </summary>
    public string TenantName { get; set; }

    /// <summary>
    /// 登录时间
    /// </summary>
    public DateTime LoginTime { get; set; }

    /// <summary>
    /// 最后活动时间
    /// </summary>
    public DateTime LastActivityTime { get; set; }

    /// <summary>
    /// 设备信息
    /// </summary>
    public string DeviceInfo { get; set; }

    /// <summary>
    /// IP地址
    /// </summary>
    public string IpAddress { get; set; }

    /// <summary>
    /// 用户代理
    /// </summary>
    public string UserAgent { get; set; }
}

/// <summary>
/// 令牌刷新请求DTO（别名）
/// </summary>
public class TokenRefreshRequestDto
{
    /// <summary>
    /// 刷新令牌
    /// </summary>
    [Required]
    public string RefreshToken { get; set; }
}

/// <summary>
/// 令牌刷新结果DTO
/// </summary>
public class TokenRefreshResultDto
{
    /// <summary>
    /// 访问令牌
    /// </summary>
    public string AccessToken { get; set; }

    /// <summary>
    /// 刷新令牌
    /// </summary>
    public string RefreshToken { get; set; }

    /// <summary>
    /// 令牌类型
    /// </summary>
    public string TokenType { get; set; }

    /// <summary>
    /// 过期时间（秒）
    /// </summary>
    public int ExpiresIn { get; set; }
}

/// <summary>
/// 令牌验证请求DTO
/// </summary>
public class TokenValidationRequestDto
{
    /// <summary>
    /// 待验证的令牌
    /// </summary>
    [Required]
    public string Token { get; set; }
}

/// <summary>
/// 令牌撤销请求DTO
/// </summary>
public class TokenRevocationRequestDto
{
    /// <summary>
    /// 要撤销的令牌
    /// </summary>
    [Required]
    public string Token { get; set; }

    /// <summary>
    /// 令牌类型
    /// </summary>
    public string TokenType { get; set; }
}

/// <summary>
/// 启用双因子认证请求DTO
/// </summary>
public class EnableTwoFactorRequestDto
{
    /// <summary>
    /// 用户密码验证
    /// </summary>
    [Required]
    public string Password { get; set; }

    /// <summary>
    /// 验证码
    /// </summary>
    public string Code { get; set; }
}

/// <summary>
/// 双因子认证设置结果DTO
/// </summary>
public class TwoFactorSetupResultDto
{
    /// <summary>
    /// 共享密钥
    /// </summary>
    public string SharedKey { get; set; }

    /// <summary>
    /// QR码数据
    /// </summary>
    public string QrCodeUri { get; set; }

    /// <summary>
    /// 恢复代码
    /// </summary>
    public List<string> RecoveryCodes { get; set; }
}

/// <summary>
/// 禁用双因子认证请求DTO
/// </summary>
public class DisableTwoFactorRequestDto
{
    /// <summary>
    /// 用户密码验证
    /// </summary>
    [Required]
    public string Password { get; set; }

    /// <summary>
    /// 双因子认证验证码
    /// </summary>
    public string Code { get; set; }
}

/// <summary>
/// 双因子认证验证请求DTO
/// </summary>
public class TwoFactorVerificationRequestDto
{
    /// <summary>
    /// 验证码
    /// </summary>
    [Required]
    [StringLength(6, MinimumLength = 6)]
    public string Code { get; set; }

    /// <summary>
    /// 记住设备
    /// </summary>
    public bool RememberDevice { get; set; }
}

/// <summary>
/// 双因子认证验证结果DTO
/// </summary>
public class TwoFactorVerificationResultDto
{
    /// <summary>
    /// 验证是否成功
    /// </summary>
    public bool Success { get; set; }

    /// <summary>
    /// 访问令牌
    /// </summary>
    public string AccessToken { get; set; }

    /// <summary>
    /// 是否需要记住设备
    /// </summary>
    public bool RememberDevice { get; set; }
}

/// <summary>
/// 发送双因子验证码请求DTO
/// </summary>
public class SendTwoFactorCodeRequestDto
{
    /// <summary>
    /// 发送方式
    /// </summary>
    public string Provider { get; set; }
}

/// <summary>
/// 重置双因子认证请求DTO
/// </summary>
public class ResetTwoFactorRequestDto
{
    /// <summary>
    /// 用户密码验证
    /// </summary>
    [Required]
    public string Password { get; set; }
}

/// <summary>
/// 生成恢复代码请求DTO
/// </summary>
public class GenerateRecoveryCodesRequestDto
{
    /// <summary>
    /// 用户密码验证
    /// </summary>
    [Required]
    public string Password { get; set; }
}

/// <summary>
/// 恢复代码结果DTO
/// </summary>
public class RecoveryCodesResultDto
{
    /// <summary>
    /// 恢复代码列表
    /// </summary>
    public List<string> RecoveryCodes { get; set; }

    /// <summary>
    /// 剩余代码数量
    /// </summary>
    public int RemainingCount { get; set; }
}

// OAuth 相关DTO
/// <summary>
/// OAuth密码授权请求DTO
/// </summary>
public class OAuthPasswordRequestDto
{
    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }

    [Required]
    public string Username { get; set; }

    [Required]
    public string Password { get; set; }

    public string Scope { get; set; }
}

/// <summary>
/// OAuth刷新令牌请求DTO
/// </summary>
public class OAuthRefreshTokenRequestDto
{
    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }

    [Required]
    public string RefreshToken { get; set; }

    public string Scope { get; set; }
}

/// <summary>
/// OAuth令牌结果DTO
/// </summary>
public class OAuthTokenResultDto
{
    public string AccessToken { get; set; }
    public string RefreshToken { get; set; }
    public string TokenType { get; set; }
    public int ExpiresIn { get; set; }
    public int RefreshExpiresIn { get; set; }
}

/// <summary>
/// 设备授权请求DTO
/// </summary>
public class DeviceAuthorizationRequestDto
{
    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }

    public string Scope { get; set; }
}

/// <summary>
/// 设备授权结果DTO
/// </summary>
public class DeviceAuthorizationResultDto
{
    public string DeviceCode { get; set; }
    public string UserCode { get; set; }
    public string VerificationUri { get; set; }
    public string VerificationUriComplete { get; set; }
    public int ExpiresIn { get; set; }
    public int Interval { get; set; }
}

// 位置和设备相关DTO
/// <summary>
/// 位置信息请求DTO
/// </summary>
public class LocationInfoRequestDto
{
    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
}

/// <summary>
/// 位置信息DTO
/// </summary>
public class LocationInfoDto
{
    public string Country { get; set; }
    public string Region { get; set; }
    public string City { get; set; }
    public double? Latitude { get; set; }
    public double? Longitude { get; set; }
    public bool IsTrustedLocation { get; set; }
}

/// <summary>
/// 位置限制检查请求DTO
/// </summary>
public class LocationRestrictionCheckRequestDto
{
    public string UserId { get; set; }
    public LocationInfoRequestDto Location { get; set; }
}

/// <summary>
/// 位置限制检查结果DTO
/// </summary>
public class LocationRestrictionCheckResultDto
{
    public bool IsAllowed { get; set; }
    public string Reason { get; set; }
    public LocationInfoDto Location { get; set; }
}

/// <summary>
/// 设备信任状态DTO
/// </summary>
public class DeviceTrustStatusDto
{
    public string DeviceId { get; set; }
    public bool IsTrusted { get; set; }
    public DateTime? TrustedUntil { get; set; }
    public string DeviceName { get; set; }
}

/// <summary>
/// 信任设备请求DTO
/// </summary>
public class TrustDeviceRequestDto
{
    public string DeviceId { get; set; }
    public bool RememberDevice { get; set; }
    public int TrustDurationDays { get; set; }
}

/// <summary>
/// 撤销设备信任请求DTO
/// </summary>
public class RevokeDeviceTrustRequestDto
{
    public string DeviceId { get; set; }
}

// 会话和策略相关DTO
/// <summary>
/// 会话策略请求DTO
/// </summary>
public class SessionPolicyRequestDto
{
    public string UserId { get; set; }
}

/// <summary>
/// 会话策略DTO
/// </summary>
public class SessionPolicyDto
{
    public bool AllowMultipleSessions { get; set; }
    public int SessionTimeoutMinutes { get; set; }
    public bool SlidingExpiration { get; set; }
}

/// <summary>
/// 更新会话策略请求DTO
/// </summary>
public class UpdateSessionPolicyRequestDto
{
    public bool AllowMultipleSessions { get; set; }
    public int SessionTimeoutMinutes { get; set; }
    public bool SlidingExpiration { get; set; }
}

/// <summary>
/// 令牌策略请求DTO
/// </summary>
public class TokenPolicyRequestDto
{
    public string UserId { get; set; }
}

/// <summary>
/// 令牌策略DTO
/// </summary>
public class TokenPolicyDto
{
    public int AccessTokenExpirationMinutes { get; set; }
    public int RefreshTokenExpirationDays { get; set; }
    public bool AllowRefreshToken { get; set; }
}

/// <summary>
/// 更新令牌策略请求DTO
/// </summary>
public class UpdateTokenPolicyRequestDto
{
    public int AccessTokenExpirationMinutes { get; set; }
    public int RefreshTokenExpirationDays { get; set; }
    public bool AllowRefreshToken { get; set; }
}

/// <summary>
/// 认证配置DTO
/// </summary>
public class AuthenticationConfigurationDto
{
    public bool RequireTwoFactor { get; set; }
    public bool RequireEmailConfirmation { get; set; }
    public bool RequirePhoneConfirmation { get; set; }
    public int MaxFailedAttempts { get; set; }
    public int LockoutDurationMinutes { get; set; }
}

/// <summary>
/// 更新认证配置请求DTO
/// </summary>
public class UpdateAuthenticationConfigurationRequestDto
{
    public bool RequireTwoFactor { get; set; }
    public bool RequireEmailConfirmation { get; set; }
    public bool RequirePhoneConfirmation { get; set; }
    public int MaxFailedAttempts { get; set; }
    public int LockoutDurationMinutes { get; set; }
}

/// <summary>
/// 批量操作请求DTO
/// </summary>
public class BatchOperationRequestDto
{
    public List<string> UserIds { get; set; }
    public string Operation { get; set; }
    public Dictionary<string, object> Parameters { get; set; }
}

// 会话相关DTO
/// <summary>
/// 获取会话请求DTO
/// </summary>
public class GetSessionsRequestDto
{
    public string UserId { get; set; }
    public bool IncludeExpired { get; set; }
    public int MaxResultCount { get; set; } = 10;
    public int SkipCount { get; set; } = 0;
}

/// <summary>
/// 认证会话DTO
/// </summary>
public class AuthSessionDto
{
    public string SessionId { get; set; }
    public string UserId { get; set; }
    public string DeviceId { get; set; }
    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
    public DateTime LoginTime { get; set; }
    public DateTime? LastActivityTime { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public bool IsActive { get; set; }
    public LocationInfoDto Location { get; set; }
}

/// <summary>
/// 撤销会话请求DTO
/// </summary>
public class RevokeSessionRequestDto
{
    public string SessionId { get; set; }
}

/// <summary>
/// 撤销所有会话请求DTO
/// </summary>
public class RevokeAllSessionsRequestDto
{
    public string UserId { get; set; }
    public string ExcludeSessionId { get; set; }
}

/// <summary>
/// 延长会话请求DTO
/// </summary>
public class ExtendSessionRequestDto
{
    public string SessionId { get; set; }
    public int ExtensionMinutes { get; set; }
}

// 权限和安全相关DTO
/// <summary>
/// 权限检查请求DTO
/// </summary>
public class PermissionCheckRequestDto
{
    public string UserId { get; set; }
    public string Permission { get; set; }
    public string Resource { get; set; }
}

/// <summary>
/// 权限检查结果DTO
/// </summary>
public class PermissionCheckResultDto
{
    public bool HasPermission { get; set; }
    public string Reason { get; set; }
    public DateTime? ExpiresAt { get; set; }
}

/// <summary>
/// API密钥验证请求DTO
/// </summary>
public class ApiKeyValidationRequestDto
{
    public string ApiKey { get; set; }
    public string Endpoint { get; set; }
    public string Method { get; set; }
}

/// <summary>
/// API密钥验证结果DTO
/// </summary>
public class ApiKeyValidationResultDto
{
    public bool IsValid { get; set; }
    public string UserId { get; set; }
    public string Role { get; set; }
    public List<string> Permissions { get; set; }
    public DateTime? ExpiresAt { get; set; }
}

/// <summary>
/// 风险评估请求DTO
/// </summary>
public class RiskAssessmentRequestDto
{
    public string UserId { get; set; }
    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
    public LocationInfoDto Location { get; set; }
    public string Action { get; set; }
}

/// <summary>
/// 风险评估结果DTO
/// </summary>
public class RiskAssessmentResultDto
{
    public float RiskScore { get; set; }
    public string RiskLevel { get; set; }
    public List<string> RiskFactors { get; set; }
    public bool IsAllowed { get; set; }
    public string Reason { get; set; }
}

/// <summary>
/// 设备信任状态请求DTO
/// </summary>
public class DeviceTrustStatusRequestDto
{
    public string UserId { get; set; }
    public string DeviceId { get; set; }
}

// 统计和报告相关DTO
/// <summary>
/// 认证统计请求DTO
/// </summary>
public class AuthenticationStatisticsRequestDto
{
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public string Granularity { get; set; } = "day";
}

/// <summary>
/// 认证统计DTO
/// </summary>
public class AuthenticationStatisticsDto
{
    public int TotalLogins { get; set; }
    public int SuccessfulLogins { get; set; }
    public int FailedLogins { get; set; }
    public int TwoFactorLogins { get; set; }
    public Dictionary<string, int> LoginsByDay { get; set; }
    public Dictionary<string, int> LoginsByLocation { get; set; }
    public Dictionary<string, int> LoginsByDevice { get; set; }
}

/// <summary>
/// 令牌统计请求DTO
/// </summary>
public class TokenStatisticsRequestDto
{
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public string TokenStatus { get; set; }
}

/// <summary>
/// 令牌统计DTO
/// </summary>
public class TokenStatisticsDto
{
    public int ActiveTokens { get; set; }
    public int ExpiredTokens { get; set; }
    public int RevokedTokens { get; set; }
    public Dictionary<string, int> TokensByType { get; set; }
    public Dictionary<string, int> TokensByClient { get; set; }
}

/// <summary>
/// 安全报告请求DTO
/// </summary>
public class SecurityReportRequestDto
{
    public string ReportType { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public string Format { get; set; } = "json";
}

/// <summary>
/// 安全报告DTO
/// </summary>
public class SecurityReportDto
{
    public string ReportId { get; set; }
    public string ReportType { get; set; }
    public DateTime GeneratedAt { get; set; }
    public object Data { get; set; }
    public int TotalRecords { get; set; }
}

/// <summary>
/// 安全数据导出请求DTO
/// </summary>
public class SecurityDataExportRequestDto
{
    public string DataType { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public string Format { get; set; } = "csv";
}

/// <summary>
/// 文件导出结果DTO
/// </summary>
public class FileExportResultDto
{
    public string FileId { get; set; }
    public string FileName { get; set; }
    public string DownloadUrl { get; set; }
    public DateTime ExpiresAt { get; set; }
    public long FileSize { get; set; }
}

/// <summary>
/// 账户安全检查请求DTO
/// </summary>
public class AccountSecurityCheckRequestDto
{
    public string UserId { get; set; }
    public List<string> CheckTypes { get; set; }
}

/// <summary>
/// 账户安全检查结果DTO
/// </summary>
public class AccountSecurityCheckResultDto
{
    public string UserId { get; set; }
    public float SecurityScore { get; set; }
    public List<SecurityIssueDto> Issues { get; set; }
    public List<SecurityRecommendationDto> Recommendations { get; set; }
}

/// <summary>
/// 安全问题DTO
/// </summary>
public class SecurityIssueDto
{
    public string Type { get; set; }
    public string Severity { get; set; }
    public string Description { get; set; }
    public string Recommendation { get; set; }
}

/// <summary>
/// 安全建议DTO
/// </summary>
public class SecurityRecommendationDto
{
    public string Title { get; set; }
    public string Description { get; set; }
    public string Priority { get; set; }
}

/// <summary>
/// 认证方法DTO
/// </summary>
public class AuthenticationMethodDto
{
    public string Method { get; set; }
    public string Name { get; set; }
    public bool IsEnabled { get; set; }
    public bool IsConfigured { get; set; }
    public DateTime? LastUsed { get; set; }
}

/// <summary>
/// 双因子认证方法DTO
/// </summary>
public class TwoFactorAuthenticationMethodDto
{
    public string Provider { get; set; }
    public string Name { get; set; }
    public bool IsEnabled { get; set; }
    public bool IsConfigured { get; set; }
    public DateTime? LastUsed { get; set; }
}

/// <summary>
/// 密码强度检查请求DTO
/// </summary>
public class PasswordStrengthRequestDto
{
    public string Password { get; set; }
    public string UserId { get; set; }
}

/// <summary>
/// 密码强度检查结果DTO
/// </summary>
public class PasswordStrengthResultDto
{
    public int StrengthScore { get; set; }
    public string StrengthLevel { get; set; }
    public List<string> Weaknesses { get; set; }
    public List<string> Suggestions { get; set; }
}

/// <summary>
/// 数据泄露检查请求DTO
/// </summary>
public class DataBreachCheckRequestDto
{
    public string Email { get; set; }
    public string PasswordHash { get; set; }
}

/// <summary>
/// 数据泄露检查结果DTO
/// </summary>
public class DataBreachCheckResultDto
{
    public bool IsBreached { get; set; }
    public List<string> BreachedSources { get; set; }
    public DateTime? FirstBreachDate { get; set; }
    public List<string> Recommendations { get; set; }
}

// 额外的OAuth相关DTO
/// <summary>
/// OAuth授权请求DTO
/// </summary>
public class OAuthAuthorizationRequestDto
{
    [Required]
    public string ClientId { get; set; }

    [Required]
    public string RedirectUri { get; set; }

    [Required]
    public string ResponseType { get; set; }

    public string Scope { get; set; }
    public string State { get; set; }
}

/// <summary>
/// OAuth授权结果DTO
/// </summary>
public class OAuthAuthorizationResultDto
{
    public string AuthorizationCode { get; set; }
    public string State { get; set; }
    public string RedirectUri { get; set; }
}

/// <summary>
/// OAuth令牌交换请求DTO
/// </summary>
public class OAuthTokenExchangeRequestDto
{
    [Required]
    public string GrantType { get; set; }

    public string Code { get; set; }
    public string RedirectUri { get; set; }
    public string ClientId { get; set; }
    public string ClientSecret { get; set; }
    public string RefreshToken { get; set; }
    public string Scope { get; set; }
}

/// <summary>
/// OAuth客户端凭据请求DTO
/// </summary>
public class OAuthClientCredentialsRequestDto
{
    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }

    public string Scope { get; set; }
}

/// <summary>
/// 设备授权状态请求DTO
/// </summary>
public class DeviceAuthorizationStatusRequestDto
{
    [Required]
    public string DeviceCode { get; set; }
}

/// <summary>
/// 设备授权状态结果DTO
/// </summary>
public class DeviceAuthorizationStatusResultDto
{
    public string Status { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public int Interval { get; set; }
    public OAuthTokenResultDto Token { get; set; }
}

/// <summary>
/// 令牌内省请求DTO
/// </summary>
public class TokenIntrospectionRequestDto
{
    [Required]
    public string Token { get; set; }

    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }
}

/// <summary>
/// 令牌内省结果DTO
/// </summary>
public class TokenIntrospectionResultDto
{
    public bool Active { get; set; }
    public string Scope { get; set; }
    public string ClientId { get; set; }
    public string Username { get; set; }
    public string TokenType { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public DateTime? IssuedAt { get; set; }
    public string Subject { get; set; }
    public List<string> Audiences { get; set; }
    public string Issuer { get; set; }
    public string Jti { get; set; }
}

/// <summary>
/// 撤销OAuth令牌请求DTO
/// </summary>
public class RevokeOAuthTokenRequestDto
{
    [Required]
    public string Token { get; set; }

    [Required]
    public string ClientId { get; set; }

    [Required]
    public string ClientSecret { get; set; }

    public string TokenTypeHint { get; set; }
}

// 用户安全相关DTO
/// <summary>
/// 获取用户安全信息请求DTO
/// </summary>
public class GetUserSecurityInfoRequestDto
{
    [Required]
    public string UserId { get; set; }

    public bool IncludeSensitiveInfo { get; set; }
}

/// <summary>
/// 用户安全信息DTO
/// </summary>
public class UserSecurityInfoDto
{
    public string UserId { get; set; }
    public bool TwoFactorEnabled { get; set; }
    public bool EmailConfirmed { get; set; }
    public bool PhoneConfirmed { get; set; }
    public DateTime? LastLoginTime { get; set; }
    public int FailedLoginAttempts { get; set; }
    public bool IsLockedOut { get; set; }
    public DateTime? LockoutEnd { get; set; }
    public List<AuthenticationMethodDto> AuthenticationMethods { get; set; }
    public List<DeviceTrustStatusDto> TrustedDevices { get; set; }
}

/// <summary>
/// 更新用户安全设置请求DTO
/// </summary>
public class UpdateUserSecuritySettingsRequestDto
{
    public bool EnableTwoFactor { get; set; }
    public bool EmailNotifications { get; set; }
    public bool SmsNotifications { get; set; }
    public List<string> TrustedIps { get; set; }
    public int SessionTimeoutMinutes { get; set; }
}

// 安全事件相关DTO
/// <summary>
/// 获取安全事件请求DTO
/// </summary>
public class GetSecurityEventsRequestDto
{
    public string UserId { get; set; }
    public string EventType { get; set; }
    public DateTime? StartDate { get; set; }
    public DateTime? EndDate { get; set; }
    public int MaxResultCount { get; set; } = 10;
    public int SkipCount { get; set; } = 0;
}

/// <summary>
/// 安全事件DTO
/// </summary>
public class SecurityEventDto
{
    public string EventId { get; set; }
    public string UserId { get; set; }
    public string EventType { get; set; }
    public string Description { get; set; }
    public DateTime EventTime { get; set; }
    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
    public bool Success { get; set; }
    public string Details { get; set; }
    public LocationInfoDto Location { get; set; }
}

/// <summary>
/// 创建安全事件请求DTO
/// </summary>
public class CreateSecurityEventRequestDto
{
    [Required]
    public string EventType { get; set; }

    [Required]
    public string Description { get; set; }

    public string UserId { get; set; }
    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
    public bool Success { get; set; }
    public string Details { get; set; }
}

/// <summary>
/// 执行风险评估请求DTO
/// </summary>
public class PerformRiskAssessmentRequestDto
{
    [Required]
    public string UserId { get; set; }

    [Required]
    public string Action { get; set; }

    public string IpAddress { get; set; }
    public string UserAgent { get; set; }
    public LocationInfoDto Location { get; set; }
    public Dictionary<string, object> Context { get; set; }
}